home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / shanghai.000 / shanghai / shanghai-1.0 / board.h < prev    next >
C/C++ Source or Header  |  1995-05-30  |  3KB  |  99 lines

  1. #include "game.h"
  2. #ifndef __BOARD_H__
  3. #define __BOARD_H__
  4.  
  5. #include <sys/time.h>
  6.  
  7. #include "forms.h"
  8. #include "gui.h"
  9. #include "icondata.h"
  10. #include "mapdata.h"
  11.  
  12. typedef struct {
  13.   int           seed;
  14.   int           remain;
  15.   int           matchcount;
  16.   int           time0,time1,time2;
  17.   int           rank;
  18.   int           scoremode;
  19.   enum dsStatus status;
  20. } InfoBoxRec;
  21.  
  22. typedef struct boardrec {
  23.   Display       *disp;
  24.   Drawable      win;
  25.   FD_board      *board;
  26.   int           paused;
  27.   int           boardnumeditable;
  28.   int           ox,oy,ow,oh;
  29.   int           seed;
  30.   unsigned char occ[144];
  31.   unsigned char ideal[144],weight[144];
  32.   unsigned char lookup[144];
  33.   unsigned char history[144],histstep[144],histpos;
  34.   unsigned char inverted[144];
  35.   unsigned char sel0,sel1;
  36.   int           remain;
  37.   int           matchcount;
  38.   struct timeval tv;
  39.   int           time;
  40.   int           rank;
  41.   int           scoremode;
  42.   int           isfastgame;
  43.   DepthScanRec  depthscan;
  44.   InfoBoxRec    infobox;
  45. } BoardRec;
  46.  
  47. #ifdef __GNUC__
  48. #define min(x,y) ({typeof(x) _x=(x);typeof(y) _y=(y); _x > _y ? _y : _x; })
  49. #define max(x,y) ({typeof(x) _x=(x);typeof(y) _y=(y); _x > _y ? _x : _y; })
  50. #define sqr(x)   ({typeof(x) _x=(x); _x*_x;})
  51. #define cubic(x) ({typeof(x) _x=(x); _x*_x*_x;})
  52. extern __inline__ int intersect(int  x1,int  y1,int  w1,int  h1,
  53.                 int  x2,int  y2,int  w2,int  h2,
  54.                 int *x3,int *y3,int *w3,int *h3)
  55. {
  56.   *x3 = max(x1,x2);
  57.   *y3 = max(y1,y2);
  58.   *w3 = min(x1+w1-1,x2+w2-1) - *x3 + 1;
  59.   *h3 = min(y1+h1-1,y2+h2-1) - *y3 + 1;
  60.   return((*w3 > 0) && (*h3 > 0));
  61. }
  62. extern __inline__ void tile_pos(int pos,int *x,int *y,int *w,int *h,
  63.                 int *ox,int *oy,int *ow,int *oh)
  64. {
  65.   int   ix,iy;
  66.  
  67.   ix = (board[pos].x*(ICON_WIDTH-DIM3DX-1))/2  + DIM3DX*board[pos].depth;
  68.   iy = (board[pos].y*(ICON_HEIGHT-DIM3DY-1))/2 - DIM3DY*board[pos].depth;
  69.   if ( x)  *x = ix+DIM3DX;
  70.   if ( y)  *y = iy+SHADOWY;
  71.   if ( w)  *w = ICON_WIDTH-DIM3DX;
  72.   if ( h)  *h = ICON_HEIGHT-DIM3DY;
  73.   if (ox) *ox = ix;
  74.   if (oy) *oy = iy;
  75.   if (ow) *ow = ICON_WIDTH+SHADOWX;
  76.   if (oh) *oh = ICON_HEIGHT+SHADOWY;
  77.   return;
  78. }
  79. #else
  80. #define __inline__
  81. #define min(x,y) ((x) > (y) ? (y) : (x))
  82. #define max(x,y) ((x) > (y) ? (x) : (y))
  83. #define sqr(x)   ((x)*(x))
  84. #define cubic(x) ((x)*(x)*(x))
  85. int intersect(int  x1,int  y1,int  w1,int  h1,
  86.           int  x2,int  y2,int  w2,int  h2,
  87.           int *x3,int *y3,int *w3,int *h3);
  88. void tile_pos(int pos,int *x,int *y,int *w,int *h,
  89.           int *ox,int *oy,int *ow,int *oh);
  90. #endif
  91.  
  92. void draw_area(int x,int y,int w,int h,BoardRec *board_rec);
  93. void draw_all_tiles(BoardRec *board_rec);
  94. void update_info_box(BoardRec *board_rec);
  95. void deactivate_board_num(BoardRec *board_rec);
  96. FD_board *new_board(void);
  97.  
  98. #endif
  99.